home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Dev / ace23.lha / PRGS.lha / IO / aterm.b next >
Text File  |  1994-01-15  |  2KB  |  89 lines

  1. '..Test of serial port functions in ACE via a simple terminal program.
  2. '..Run this program from a shell/CLI. There is NO translation of
  3. '..incoming escape sequences.
  4.  
  5. DEFLNG   a-z
  6.  
  7. LIBRARY "graphics.library"
  8. DECLARE FUNCTION SetDrMd(Rp&,MODE) LIBRARY
  9.  
  10. CONST    true=-1&, false=0&
  11. CONST     buffer_size=1024&
  12. CONST     unit=0&
  13. CONST     COMPLEMENT=2&,JAM2=1&
  14.  
  15. STRING   buffer, parity, data_bits, stop_bits, wires, Xon, share, fast
  16. LONGINT  baud, chars, maxcolor, rp
  17.  
  18. SUB cursoron
  19. shared maxcolor,rp
  20.   SetDrMd(rp,COMPLEMENT)
  21.   color maxcolor 
  22.   print "|";
  23.   color 1
  24.   SetDrMd(rp,JAM2)
  25. END SUB
  26.  
  27. SUB cursoroff
  28. shared maxcolor,rp
  29.   SetDrMd(rp,COMPLEMENT)
  30.   locate csrlin,pos-1
  31.   color maxcolor
  32.   print "|"+chr$(8);
  33.   color 1
  34.   SetDrMd(rp,JAM2)
  35. END SUB
  36.  
  37. '..main
  38. if argcount<>4 then 
  39.   print "usage: ";arg$(0);" baud parity data stop"
  40.   STOP
  41. else
  42.   '..get serial parameters
  43.   baud=val(arg$(1))
  44.   parity=arg$(2)
  45.   data_bits=arg$(3)
  46.   stop_bits=arg$(4)
  47.   wires="7"
  48.   Xon="X"
  49.   share="?"
  50.   fast="?"
  51.   param$ = parity+data_bits+stop_bits+wires+Xon+share+fast
  52. end if
  53.  
  54. window 1,"ACE Terminal (hit ESC to quit)",(0,0)-(640,200)
  55.  
  56. maxcolor = window(6)
  57. rp = window(8)
  58.  
  59. on error goto quit
  60. error on
  61.  
  62. serial open 1,unit,baud,param$,1024
  63.  
  64. cursoron
  65.  
  66. finished=false
  67.  
  68. repeat
  69.   '..incoming?
  70.   chars = serial(1,0)
  71.   if chars<>0 then 
  72.     serial read 1,buffer,chars
  73.     cursoroff
  74.     print buffer;
  75.     cursoron
  76.   end if  
  77.   '..outgoing?
  78.   k$=inkey$
  79.   if k$=chr$(27) then 
  80.     finished=true
  81.   else
  82.     if k$<>"" then serial write 1,k$,1
  83.   end if
  84. until finished
  85.  
  86. quit:
  87.   window close 1
  88.   serial close 1
  89.